<template>
  <div class="BigCard">
    <!-- 面包屑导航 -->
    <el-breadcrumb separator="/">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>订单管理</el-breadcrumb-item>
      <el-breadcrumb-item>订单列表</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 卡片视图 -->
    <el-card class="box-card">
      <el-row :gutter="20" style="padding-bottom:15px">
        <el-col :span="7">
          <el-input placeholder="请输入内容" v-model="queryInfo.query">
            <el-button slot="append" icon="el-icon-search"></el-button>
          </el-input>
        </el-col>
      </el-row>
      <!-- 列表部分 -->
      <template>
        <el-table :data="DDList" border style="width: 100%">
          <el-table-column type="index" label="#" width="50px"></el-table-column>
          <el-table-column prop="order_number" label="订单编号"></el-table-column>
          <el-table-column prop="order_price" label="订单价格"></el-table-column>
          <el-table-column label="是否付款">
            <template slot-scope="scope">
              <el-tag v-if='!scope.row.order_pay'>已付款</el-tag>
              <el-tag type="danger" else-if>未付款</el-tag>
            </template>
          </el-table-column>
          <el-table-column prop="is_send" label="是否发货"></el-table-column>
          <el-table-column prop="create_time" label="下单时间"></el-table-column>
          <el-table-column label="操作" width="180px">
          </el-table-column>
        </el-table>
      </template>
      <!-- 分页 -->
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="queryInfo.pagenum"
        :page-sizes="[2,5,10,20]"
        :page-size="queryInfo.pagesize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      ></el-pagination>
    </el-card>
  </div>
</template>      
<script>
import { ordersGet_api } from "../../api/index.js";
export default {
  data() {
    return {
      // 存分页数据
      queryInfo: {
        query: "",
        pagenum: 1,
        pagesize: 10,
      },
      DDList: [],
      total: 0,
    };
  },
  methods: {
    // 分页功能
    handleSizeChange(newSize) {
      this.queryInfo.pagesize = newSize;
      this.Getlist();
    },
    handleCurrentChange(current) {
      this.queryInfo.pagenum = current;
      this.Getlist();
    },
    // 获取数据
    async Getlist() {
      const { data: res } = await ordersGet_api(this.queryInfo);
      console.log(res,222);
      this.DDList = res.data.goods;
      this.total = res.data.total;
    },
  },
  // 创建完后渲染数据
  created() {
    this.Getlist();
  },
};
</script>
<style scoped>
.BigCard {
  width: 100%;
  height: 100%;
}
.text {
  font-size: 14px;
}

.item {
  margin-bottom: 18px;
}

.clearfix:before,
.clearfix:after {
  display: table;
  content: "";
}
.clearfix:after {
  clear: both;
}

.box-card {
  margin-top: 5px;
  width: 100%;
}
</style>